<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
  <title>欢迎使用领捷智慧物流管理系统</title>
  <link rel="hshortcut icon" href="../static/img/own/head.png"/>
  <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i">
  <link rel="stylesheet" href="/static/fonts/fontawesome-all.min.css">
  <link rel="stylesheet" href="/static/css/animate.min.css">
</head>

<body id="page-top">
<div id="wrapper">
  <div class="d-flex flex-column" id="content-wrapper">
    <div id="content">
      <div style="height: 100%;min-width: 0px;">
        <div class="container border rounded" style="min-width: 100%;width: auto;margin-bottom: 0px;padding: 0px;padding-top: 0px;padding-right: 0px;padding-bottom: 0px;padding-left: 0px;height: auto;margin-right: 0px;">
          <div class="row" style="margin-right: 0px;margin-left: 0px;">
            <div class="col" style="margin-left: 24px;padding: 13px;background: rgba(255,255,255,0.1);margin-right: 24px;"><span style="font-size: 25px;color: rgb(0,0,0);padding-left: 0px;">新建仓库：</span></div>
          </div>
        </div>
        <div class="container text-left d-inline-flex justify-content-center" style="width: 100%;height: auto;margin: 0px;padding: 0px;margin-right: 0;margin-left: 0;max-width: none;min-width: auto;">
          <form id="addWarehouseForm"  action="/warehouse/addWarehouse" method="post" onsubmit="return fabu(this)" class="border rounded d-inline-flex flex-column justify-content-start justify-content-xl-start" style="margin-right: 24px;margin-left: 24px;background: rgba(255,255,255,0.1);height: auto;padding: 13px;width: 100%;"><span style="font-size: 18px;color: rgb(0,0,0);margin-left: 21px;margin-top: 0px;padding: 0px;padding-top: 0px;">仓库信息</span>
            <hr style="border-width: 1px;">
<!--            <div class="form-group text-monospace text-center d-inline-flex justify-content-center" style="height: auto;margin-left: 0px;margin-right: 0px;width: 100%;max-height: 100%;padding-left: 0px;"><span style="color: rgb(0,0,0);line-height: 40px;">仓库编号</span><input class="form-control" type="text" style="width: 350px;margin-left: 10px;" placeholder="请输入商品种类"></div>-->
            <div class="form-group text-monospace text-center d-inline-flex justify-content-center visible"
                 style="width: auto;padding-right: 0px;" ><span style="color: rgb(0,0,0);font-size: 16px;line-height: 40px;">仓库名</span><input class="form-control" type="text" style="width: 350px;margin-left: 10px;" placeholder="请输入仓库名称" name="housename"></div>
            <div class="form-group text-monospace text-center d-inline-flex justify-content-center"
                 style="height: auto;margin-left: 0px;margin-right: 0px;width: 100%;max-height: 100%;padding-left: 0px;"><span style="color: rgb(0,0,0);line-height: 40px;">仓库信息</span><textarea class="form-control" style="width: 350px;margin-left: 10px;" name="houseinfo"></textarea></div>
            <div class="form-group text-monospace text-center d-inline-flex justify-content-center"
                 style="height: auto;margin-left: 0px;margin-right: 0px;width: 100%;max-height: 100%;padding-left: 0px;"><button class="btn btn-primary"  type="submit" style="width: 80px;">发布</button><button class="btn btn-primary" type="button" id="goBack" style="width: 80px;margin-left: 10px;">返回</button></div>
          </form>
        </div>
      </div>


          </div>
        </div>
      </div>

      <footer class="bg-white sticky-footer">
        <div class="container my-auto">
          <div class="text-center my-auto copyright"><span>鄂ICP备2021022432号</span></div>
        </div>
      </footer>
    </div><a class="border rounded d-inline scroll-to-top" href="#page-top"><i class="fas fa-angle-up"></i></a>
  </div>
</div>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
<script src="/static/js/chart.min.js"></script>
<script src="/static/js/bs-init.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.4.1/jquery.easing.js"></script>
<script src="/static/js/script.min.js"></script>
<script src="/static/js/theme.js"></script>
<script src="/static/js/jquery.session.js"></script>

<script>
  var houseid = $("#houseid").val();
  var housename = $("#housename").val();
  var isnull = true;
$(function (){
  $("#goBack").on("click",function (){
    $(location).attr("href","/page/toWarehouse");
  })
})

function fabu(formvalue){
  var housename = formvalue.housename.value;
  var houseinfo = formvalue.houseinfo.value;
  if(""==housename||""==houseinfo){
    isnull = false;
    alert("请不要输入空值！");
    return false;
  }
}

//先判断是否已有此仓库，再添加仓库
$(function () {
  $('#addWarehouseForm').on('submit', function (e) {
    e.preventDefault();
    if(isnull == false){
      isnull = true;
      return false;
    }
    $.ajax({
      type: 'POST',
      url: '/warehouse/judgeWarehouse',
      data: $('#addWarehouseForm').serialize(),
      success: function(response) {
        if(response == "fail"){
          alert("仓库已存在！");
          return false;
        }else if(response == "success"){
          $.ajax({
            type: 'POST',
            url: '/warehouse/addWarehouse',
            data: $('#addWarehouseForm').serialize(),
            success: function(result) {
              if(result == "success"){
                alert("添加成功！");
                $(location).attr("href","/page/toWarehouse");
              }
            }
          });
        }
      }
    });
  })
})

//session
$.session.set("url",window.location.href);

</script>

</body>
</html>